package factory.factoryMethod;

interface Car {
    void name();
}

class Bus implements Car {
    @Override
    public void name() {
        System.out.println("Car");
    }
}

class Vehicle implements Car {
    @Override
    public void name() {
        System.out.println("Vehicle");
    }
}

interface CarFactory {
    Car getCar();
}

class BusFactory implements CarFactory{
    @Override
    public Car getCar() {
        return new Bus();
    }
}

class VehicleFactory implements CarFactory{
    @Override
    public Car getCar() {
        return new Vehicle();
    }
}

public class Consumer {
    public static void main(String[] args) {
        Car bus = new BusFactory().getCar();
        bus.name();

        Car vehicle = new VehicleFactory().getCar();
        vehicle.name();
    }
}